from lxml import etree
if __name__ == "__main__":
    #实例化好了一个etree对象，且将被解析的源码加载到了该对象中
    tree = etree.parse('sougou.html')
    #r = tree.xpath('/html/body/div')
    #r = tree.xpath('/html//div')
    #r = tree.xpath('//div') # //所有任意位置
    #r = tree.xpath('//div[@class="song"]')
    #r = tree.xpath('//div[@class="tang"]//li[4]//text()')[0] #索引从1开始
    r = tree.xpath('//div[@class="song"]/a/@href')[0] 
    v = tree.xpath('//div[@class="song"]/a/@title')[0]
    print(r,v)